package com.sharding.demo.config;

/**
 * @author Administrator
 * @since JDK 1.8
 **/
public class MemberIdShardingSchemeAlgorithm implements PreciseShardingAlgorithm<Integer>  {
    @Override
    public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Integer> shardingValue) {
        for ( String str : availableTargetNames ){
            int index = shardingValue.getValue() % 100;
            return str + (index > 49 ? "2" : "1");
        }
        return null;
    }

}
